import Vue from 'vue'
import App from './App.vue'

// 引入element-ui
import {
    Message, 
    Pagination, 
    MessageBox, 
    Form, 
    Button, 
    FormItem, 
    Input, 
    Select, 
    Switch,
    Option,
    Upload,
    Tooltip,
    Dialog
} from 'element-ui'
// 引入图片懒加载
import VueLazyload from "vue-lazyload"
Vue.config.productionTip = false

// 引入路由
import router from "@/router";
import store from '@/store';

// 引入全局组件
import Carousel from '@/components/Carousel'

// 注册全局组件
Vue.component(Carousel.name, Carousel)

// 引入样式文件
import "@/assets/iconfont/iconfont.js"
import "@/assets/iconfont/iconfont.css"
import "@/assets/reset.css"

import 'element-ui/lib/theme-chalk/index.css';
// 引入swiper样式
import "swiper/css/swiper.css"

// 引入mock
import "@/mock/mockServer"

// 使用插件
Vue.use(Pagination);
Vue.use(Form);
Vue.use(Button)
Vue.use(FormItem);
Vue.use(Input);
Vue.use(Select);
Vue.use(Switch);
Vue.use(Option);
Vue.use(Upload);
Vue.use(Tooltip);
Vue.use(Dialog);

// 引入图片
import loadimage from "@/assets/img/loadimage.jpg";
import errorimage from "@/assets/img/loaderror.jpg";
Vue.use(VueLazyload,{
    // 懒加载默认的图片
    loading:loadimage,
    // 图片加载失败图片
    error:errorimage,
    preLoad: 1,
    attempt: 1,
    listenEvents: [ 'scroll' ]
});

new Vue({
    render: h => h(App),
    router,
    store,
    // 创建一条总线
    beforeCreate() {
        Vue.prototype.$bus = this;
        Vue.prototype.$message = Message;
        Vue.prototype.$msgbox = MessageBox;
    }
}).$mount('#app')
